import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class HJ20 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextLine()) {
            String password = sc.nextLine();
            if(checkLength(password) &&
                    checkSymbolNumber(password) &&
                    hasDeRepeatStr(password)) {
                System.out.println("OK");
            }else {
                System.out.println("NG");
            }
        }
    }

    //检测长度是否大于8
    public static boolean checkLength(String password) {
        return password.length() > 8;
    }
    //包括大小写字母.数字.其它符号,以上四种至少三种
    public static boolean checkSymbolNumber(String password) {
        //分别代表小写字母，大写字母，数字，其它符号
        String[] str = {"[a-z]","[A-Z]","[0-9]","[^a-zA-Z0-9]"};
        int count = 0;

        for(int i =0; i < str.length; i++) {
            Pattern pattern = Pattern.compile(str[i]);
            //是否在password中有匹配的字符串
            Matcher m = pattern.matcher(password);
            if(m.find()){
                count++;
            }
        }

        return count >= 3;
    }
    //不能有相同长度超2的子串重复
    public static boolean hasDeRepeatStr(String password) {
        for(int i = 0; i < password.length() - 2; i++) {
            //从头遍历取3位字符
            String tmp = password.substring(i, i+3);
            //除去遍历到的这个字符串剩下的字符
            String rest = password.substring(i + 1);
            if(rest.contains(tmp)) {
                return false;
            }
        }

        return true;
    }
}
